load(
    "@rules_rust//rust:defs.bzl",
    "rust_doc",
    "rust_doc_test",
    "rust_library",
    "rust_test",
    "rust_test_suite",
)

rust_library(
    name = "nativelink-store",
    srcs = [
        "src/ac_utils.rs",
        "src/callback_utils.rs",
        "src/cas_utils.rs",
        "src/common_s3_utils.rs",
        "src/completeness_checking_store.rs",
        "src/compression_store.rs",
        "src/dedup_store.rs",
        "src/default_store_factory.rs",
        "src/existence_cache_store.rs",
        "src/fast_slow_store.rs",
        "src/filesystem_store.rs",
        "src/gcs_client/client.rs",
        "src/gcs_client/mocks.rs",
        "src/gcs_client/mod.rs",
        "src/gcs_client/types.rs",
        "src/gcs_store.rs",
        "src/grpc_store.rs",
        "src/lib.rs",
        "src/memory_store.rs",
        "src/mongo_store.rs",
        "src/noop_store.rs",
        "src/ontap_s3_existence_cache_store.rs",
        "src/ontap_s3_store.rs",
        "src/redis_store.rs",
        "src/redis_utils/ft_aggregate.rs",
        "src/redis_utils/mod.rs",
        "src/ref_store.rs",
        "src/s3_store.rs",
        "src/shard_store.rs",
        "src/size_partitioning_store.rs",
        "src/store_manager.rs",
        "src/verify_store.rs",
    ],
    proc_macro_deps = [
        "@crates//:async-trait",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//nativelink-config",
        "//nativelink-error",
        "//nativelink-metric",
        "//nativelink-proto",
        "//nativelink-util",
        "@crates//:async-lock",
        "@crates//:aws-config",
        "@crates//:aws-sdk-s3",
        "@crates//:aws-smithy-runtime-api",
        "@crates//:aws-smithy-types",
        "@crates//:base64",
        "@crates//:bincode",
        "@crates//:blake3",
        "@crates//:byteorder",
        "@crates//:bytes",
        "@crates//:bytes-utils",
        "@crates//:const_format",
        "@crates//:fred",
        "@crates//:futures",
        "@crates//:gcloud-auth",
        "@crates//:gcloud-storage",
        "@crates//:hex",
        "@crates//:http",
        "@crates//:http-body",
        "@crates//:http-body-util",
        "@crates//:hyper",
        "@crates//:hyper-rustls",
        "@crates//:hyper-util",
        "@crates//:itertools",
        "@crates//:lz4_flex",
        "@crates//:mongodb",
        "@crates//:opentelemetry",
        "@crates//:parking_lot",
        "@crates//:patricia_tree",
        "@crates//:prost",
        "@crates//:rand",
        "@crates//:regex",
        "@crates//:reqwest",
        "@crates//:reqwest-middleware",
        "@crates//:rustls",
        "@crates//:rustls-pemfile",
        "@crates//:serde",
        "@crates//:serde_json",
        "@crates//:sha2",
        "@crates//:tokio",
        "@crates//:tokio-stream",
        "@crates//:tokio-util",
        "@crates//:tonic",
        "@crates//:tracing",
        "@crates//:uuid",
    ],
)

rust_test_suite(
    name = "integration",
    timeout = "short",
    srcs = [
        "tests/ac_utils_test.rs",
        "tests/completeness_checking_store_test.rs",
        "tests/compression_store_test.rs",
        "tests/dedup_store_test.rs",
        "tests/existence_store_test.rs",
        "tests/fast_slow_store_test.rs",
        "tests/filesystem_store_test.rs",
        "tests/gcs_client_test.rs",
        "tests/gcs_store_test.rs",
        "tests/memory_store_test.rs",
        "tests/mongo_store_test.rs",
        "tests/ontap_s3_existence_cache_store_test.rs",
        "tests/ontap_s3_store_test.rs",
        "tests/redis_store_test.rs",
        "tests/ref_store_test.rs",
        "tests/s3_store_test.rs",
        "tests/shard_store_test.rs",
        "tests/size_partitioning_store_test.rs",
        "tests/verify_store_test.rs",
    ],
    proc_macro_deps = [
        "//nativelink-macro",
        "@crates//:async-trait",
    ],
    deps = [
        ":nativelink-store",
        "//nativelink-config",
        "//nativelink-error",
        "//nativelink-metric",
        "//nativelink-proto",
        "//nativelink-util",
        "@crates//:async-lock",
        "@crates//:aws-sdk-s3",
        "@crates//:aws-smithy-runtime",
        "@crates//:aws-smithy-runtime-api",
        "@crates//:aws-smithy-types",
        "@crates//:bincode",
        "@crates//:bytes",
        "@crates//:fred",
        "@crates//:futures",
        "@crates//:hex",
        "@crates//:http",
        "@crates//:http-body",
        "@crates//:memory-stats",
        "@crates//:mock_instant",
        "@crates//:mongodb",
        "@crates//:opentelemetry",
        "@crates//:parking_lot",
        "@crates//:pretty_assertions",
        "@crates//:rand",
        "@crates//:serde_json",
        "@crates//:serial_test",
        "@crates//:sha2",
        "@crates//:tempfile",
        "@crates//:tokio",
        "@crates//:tokio-stream",
        "@crates//:tracing",
        "@crates//:tracing-test",
        "@crates//:uuid",
    ],
)

rust_test(
    name = "unit_test",
    timeout = "short",
    crate = ":nativelink-store",
    proc_macro_deps = [
        "//nativelink-macro",
    ],
    deps = [
        "@crates//:aws-sdk-s3",
        "@crates//:aws-smithy-runtime",
        "@crates//:aws-smithy-runtime-api",
        "@crates//:aws-smithy-types",
        "@crates//:fred",
        "@crates//:http",
        "@crates//:memory-stats",
        "@crates//:mock_instant",
        "@crates//:pretty_assertions",
        "@crates//:rand",
        "@crates//:serde_json",
        "@crates//:sha2",
    ],
)

rust_doc(
    name = "docs",
    crate = ":nativelink-store",
    visibility = ["//visibility:public"],
)

rust_doc_test(
    name = "doc_test",
    timeout = "short",
    crate = ":nativelink-store",
)
